[C#] LINQ Group By


In some scenarios, we would like to select each first one row
of the group which we group by personId.

The following code block is a simple example.

var memberList =
    memberSourceData.GroupBy(item => item.personId)
        .Select(chunck => chunck
            .OrderByDescending(c => c.Id)
            .First())
        .ToList();
#C#






你可能感興趣的文章

JS註冊組|學習筆記|JavaScript&jQuery網站互動設計程式進化之道

JS註冊組|學習筆記|JavaScript&jQuery網站互動設計程式進化之道

Privacy 隱私權政策

Privacy 隱私權政策

開啟測試這扇門的鑰匙

開啟測試這扇門的鑰匙






留言討論